<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request as request;
use App\Http\Controllers\UserController;
use App\Http\Controllers\ApiController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
    // return 'Hello World';
});

//测试控制器路由写法
// Route::get('/home/test/test1',[TestController::class,'test1']);

//用户登录页
// Route::match(['get','post'],'/user/login',function(Request $request){
//     if ($request->isMethod('get')){
//         // echo $request->input('user')."<br />";
//         return view('user.login');
//     }elseif($request->isMethod('post')){
//         // echo $request->input('L_username')."<br />";
//         // echo $request->input('L_pass');
//         [TestController::class,'test1']
//     }
// })->name('login');

//登录页
Route::get('/user/login',function(){
    return view('user.login');
});
Route::post('/user/login',[UserController::class,'login'])->name('login');
// //主页
// Route::get('/user/index',[UserController::class,'index']);
//用户注册页
Route::get('/user/register', function () {
    return 'Hello 这是注册页！';
});
//用户添加页
Route::get('/user/root_add', function () {
    return 'Hello 账号添加页！';
});


// // 首页
// Route::get('/user/index',[UserController::class,'index'])->middleware('isLogin');
// // 已发送商品
// Route::get('/user/send',[UserController::class,'send'])->middleware('isLogin');
// //  添加商品
// Route::get('/user/add',[UserController::class,'add'])->middleware('isLogin');
// //上传文件接口
// Route::post('/user/upload_img',[UserController::class,'upload_img'])->middleware('isLogin');
// // Route::post('/user/upload_img',[UserController::class,'upload_file'])->middleware('isLogin');
// //数据接口，获取商品列表
// Route::get('/user/get_list',[UserController::class,'get_list'])->middleware('isLogin');
// //数据接口，添加商品数据
// Route::post('/user/goods_add',[UserController::class,'goods_add'])->middleware('isLogin');
// //数据接口，识别主图
// Route::post('/user/discern_img',[UserController::class,'discern_img'])->middleware('isLogin');
// // Route::middleware(['isLogin'])->match(['get'],'/getAllFudai',[UserController::class,'index']);//配置API
// //数据接口，大咖在线选品
// Route::get('/user/daka_list',[UserController::class,'daka_list'])->middleware('isLogin');
// Route::get('/user/daka_goods',[UserController::class,'daka'])->middleware('isLogin');
// Route::post('/user/daka_goods_add',[UserController::class,'daka_goods_add'])->middleware('isLogin');
// Route::get('/user/iframe',[UserController::class,'iframe'])->middleware('isLogin');
// Route::post('/user/edit',[UserController::class,'edit'])->middleware('isLogin');
// Route::get('/user/goods_list_order',[UserController::class,'goods_list_order'])->middleware('isLogin');

// //发单配置
// Route::get('/user/fd',[UserController::class,'fd'])->middleware('isLogin');
// //采集群
// Route::get('/user/cj',[UserController::class,'cj'])->middleware('isLogin');
// //推广位
// Route::get('/user/position',[UserController::class,'position'])->middleware('isLogin');
// //全局设置
// Route::get('/user/config',[UserController::class,'config'])->middleware('isLogin');
// //发单设置
// Route::post('/user/fconfig',[UserController::class,'fconfig'])->middleware('isLogin');
// //取群数据
// Route::get('/user/get_friends',[UserController::class,'get_friends'])->middleware('isLogin');
// //获取全局配置
// Route::post('/user/get_qj_config',[UserController::class,'get_qj_config'])->middleware('isLogin');
// //写入全局配置
// Route::post('/user/write_config',[UserController::class,'write_config'])->middleware('isLogin');

Route::group(['prefix'=>'user','middleware'=>('isLogin')],function(){
    // 首页
    Route::get('index',[UserController::class,'index']);
    // 已发送商品
    Route::get('send',[UserController::class,'send']);
    //  添加商品
    Route::get('add',[UserController::class,'add']);
    //上传文件接口
    Route::post('upload_img',[UserController::class,'upload_img']);
    //数据接口，获取商品列表
    Route::get('get_list',[UserController::class,'get_list']);
    //数据接口，添加商品数据
    Route::post('goods_add',[UserController::class,'goods_add']);
    //数据接口，识别主图
    Route::post('discern_img',[UserController::class,'discern_img']);
    //数据接口，大咖在线选品
    Route::get('daka_list',[UserController::class,'daka_list']);
    Route::get('daka_goods',[UserController::class,'daka']);
    Route::post('daka_goods_add',[UserController::class,'daka_goods_add']);
    Route::get('iframe',[UserController::class,'iframe']);
    Route::post('edit',[UserController::class,'edit']);
    Route::get('goods_list_order',[UserController::class,'goods_list_order']);

    //发单配置
    Route::get('fd',[UserController::class,'fd']);
    //采集群
    Route::get('cj',[UserController::class,'cj']);
    //推广位
    Route::get('position',[UserController::class,'position']);
    //全局设置
    Route::get('config',[UserController::class,'config']);
    //发单设置
    Route::post('fconfig',[UserController::class,'fconfig']);
    //取群数据
    Route::get('get_friends',[UserController::class,'get_friends']);
    //获取全局配置
    Route::post('get_qj_config',[UserController::class,'get_qj_config']);
    //写入全局配置
    Route::post('write_config',[UserController::class,'write_config']);
});

//后台退出登录
Route::get('/user/logout',[UserController::class,'logout']);

//api
//通讯录上传
Route::post('/api/friends_up',[ApiController::class,'friends_up']);
Route::post('/api/index',function(){
    return 'index';
});
//读取配置接口
Route::get('/api/read_config',[ApiController::class,'read_config']);
//转链接口
Route::get('/api/promotion',[ApiController::class,'promotion']);
//采集接口
Route::post('/api/caiji_up',[ApiController::class,'caiji_up']);
//登录接口
Route::post('/api/login',[ApiController::class,'login']);
//获取商品接口接口
Route::get('/api/goods_list_one',[ApiController::class,'goods_list_one']);
//下架商品接口接口
Route::get('/api/goods_up',[ApiController::class,'goods_up']);

//测试
Route::get('/user/test',[UserController::class,'test']);
